﻿@model eShop.Web.Mobile.Models.CategoryModel
@{
    Layout = null;
}
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>@Model.CategoryInfo.Name-@{@WorkContext.ShopConfig.SiteTitle}触屏版</title>
    @Html.Raw(WorkContext.ShopConfig.SEOKeyword)
    @Html.Raw(WorkContext.ShopConfig.SEODescription)
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link href="@{@WorkContext.CSSCDN}/mobile/themes/default/css/base.css" rel="stylesheet" type="text/css">
    <link href="@{@WorkContext.CSSCDN}/mobile/themes/default/css/list.css" rel="stylesheet" type="text/css">
    <script src="@{@WorkContext.ScriptCDN}/mobile/scripts/jquery.js" type="text/javascript"></script>
    <script src="@{@WorkContext.ScriptCDN}/mobile/scripts/common.js" type="text/javascript"></script>
</head>

<body>
@Html.Partial("_header")
<script type="text/javascript">
    $("#headerTitle").html("@Model.CategoryInfo.Name");

    //清空数据
    function clearText()
    {
         document.getElementById('keyword').value = '';
    }
</script>

<div class="searchBox">
	<div class="newSearch">
        <input type="text" id="keyword" name="keyword" class="new-srch-input" value="" style="color:#999999;">
        <a href="#" onclick="clearText()" target="_self" class="new-s-close"></a>
        <a href="javascript:search(document.getElementById('keyword').value);" target="_self" class="new-s-srch"><span></span></a>
    </div>
</div>

<script type="text/javascript">
    function filterBlockSH(type) {
        if (type == 0) {
            document.getElementById("filterBlock1").style.display = "none";
            document.getElementById("filterBlock2").style.display = "none";
            document.getElementById("filterBlock3").style.display = "none";
        }
        else {
            document.getElementById("filterBlock1").style.display = "block";
            document.getElementById("filterBlock2").style.display = "block";
            document.getElementById("filterBlock3").style.display = "block";
        }
    }

    function filterItemSH(obj) {
        var divList1 = obj.parentNode.parentNode.getElementsByTagName("div");
        for (var i = 0; i < divList1.length; i++) {
            divList1[i].style.display = "none";
        }

        var divList2 = obj.parentNode.getElementsByTagName("div");
        for (var i = 0; i < divList2.length; i++) {
            divList2[i].style.display = "block";
        }
    }
</script>
<div class="proList">

<div class="new-tab-type">
	<div class="new-tbl-type">
        <a href="javascript:void(0)" class="new-tbl-cell on"><span class="new-bar"></span><span class="new-p-re">排序<span class="new-icon-down"></span></span></a>
        <a href="javascript:filterBlockSH(1)" class="new-tbl-cell"><span class="new-bar"></span><span class="icon">筛选<span></span></span></a>            
    </div>
</div>
        
<div class="new-tab-type2" style="overflow:hidden;height:34px">
<div class="new-tbl-type">
<a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", Model.SortDirection == 0 ? 1 : 0 }, { "page", 1 } })" class="new-tbl-cell w60"><span @if (Model.SortColumn == 0)
                                                                                                                                                                                                                                                                                                                                                 {<text>class="on"</text>}>销量@{if (Model.SortDirection == 1 && Model.SortColumn == 0){ <text>↓</text>}else if (Model.SortDirection == 0 && Model.SortColumn == 0){ <text>↑</text>}}</span></a>
<a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 1 }, { "sortDirection", Model.SortDirection == 0 ? 1 : 0 }, { "page", 1 } })" class="new-tbl-cell w60"><span @if (Model.SortColumn == 1)
                                                                                                                                                                                                                                                                                                                                                 {<text>class="on"</text>}>价格@{if (Model.SortDirection == 1 && Model.SortColumn == 1){ <text>↓</text>}else if (Model.SortDirection == 0 && Model.SortColumn == 1){ <text>↑</text>}}</span></a>
<a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 2 }, { "sortDirection", Model.SortDirection == 0 ? 1 : 0 }, { "page", 1 } })" class="new-tbl-cell w60"><span @if (Model.SortColumn == 2)
                                                                                                                                                                                                                                                                                                                                                 {<text>class="on"</text>}>评价@{if (Model.SortDirection == 1 && Model.SortColumn == 2){ <text>↓</text>}else if (Model.SortDirection == 0 && Model.SortColumn == 2){ <text>↑</text>}}</span></a>
<a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 4 }, { "sortDirection", Model.SortDirection == 0 ? 1 : 0 }, { "page", 1 } })" class="new-tbl-cell w60"><span @if (Model.SortColumn == 4)
                                                                                                                                                                                                                                                                                                                                                 {<text>class="on"</text>}>人气@{if (Model.SortDirection == 1 && Model.SortColumn == 4){ <text>↓</text>}else if (Model.SortDirection == 0 && Model.SortColumn == 4){ <text>↑</text>}}</span></a>
</div>
</div>

<div id="categoryProductListBlock">
@foreach (PartProductInfo info in Model.ProductList)
{
<div class="proItme">
<a href="@Url.Action("product", new RouteValueDictionary { { "pid", info.Pid } })">
    <img src="@{@WorkContext.ImageCDN}/upload/product/show/thumb100_100/@info.ShowImg" width="100" height="100" class="img" />
    <span class="proDt">
        <strong class="proDD DD1">@info.Name</strong>
        <b class="proDD DD3">￥@info.ShopPrice</b>
        <p class="proDD DD4">@info.ReviewCount 人评价，@Html.Raw(info.GetStarLevel().ToString())%好评</p>
    </span>
</a>
@*<div class="ico"><a href="#">赠</a><a href="#" style="background:red;">减</a></div>*@
</div>
}
</div>
<div class="loading">
@if (Model.PageModel.HasNextPage)
{
<a id="loadBut" href="javascript:getCategoryProductList(@Model.CateId,@Model.BrandId,@Model.FilterPrice,'@Model.FilterAttr',0,@Model.SortColumn,@Model.SortDirection,cpListNextPageNumber);" class="loadMore"><span>加载更多</span></a>
<a id="lastPagePrompt" style="display:none;" href="javascript:void(0);" class="loadMore">没有了</a>
}
else
{
<a id="loadBut" style="display:none;" href="javascript:void(0);" class="loadMore"><span>加载更多</span></a>
<a id="lastPagePrompt" href="javascript:void(0);" class="loadMore">没有了</a>
}
<div id="loadPrompt" style="display:none;" class="loadAnimate"><p class="list-loading"><span></span>加载中...</p></div>
</div>

</div>

<div id="filterBlock1" class="bg" style="display:none;position:absolute;left:0px;top:0px;background-color:rgb(13, 13, 13);filter:alpha(opacity=60);opacity: 0.6;width:100%;height:100%;z-index:8888;"></div>
<a id="filterBlock2" href="javascript:filterBlockSH(0)" class="new-abtn-slid" style="display:none;z-index:8889;left:auto;right:185px;"></a>
<div id="filterBlock3" class="selectR" style="display:none;">
<ul>
    @if (Model.FilterAttr.Length == 0)
    {
        if (Model.AAndVList.Count > 0)
        {
            StringBuilder attrRouteValue = new StringBuilder();
            for (int i = 0; i < Model.AAndVList.Count; i++)
            {
                attrRouteValue.Append("0-");
            }
            Model.FilterAttr = attrRouteValue.Remove(attrRouteValue.Length - 1, 1).ToString();
        }
        else
        {
            Model.FilterAttr = "0";
        }
    }
    
    @if (Model.BrandList.Count > 0)
    {
    <li>
        <a href="javascript:void(0)" onclick="filterItemSH(this)" class="dt">品牌</a>
        <div class="selectCon">
            <ul>
                <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", 0 }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (Model.BrandId == 0)
                                                                                                                                                                                                                                                                                           { <text>class="on"</text>}><span>不限</span></a></li>
                @foreach (BrandInfo info in Model.BrandList)
                {
                <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", info.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (Model.BrandId == info.BrandId)
                                                                                                                                                                                                                                                                                                      {<text>class="on"</text>}><span>@info.Name</span></a></li>
                }
            </ul>
        </div>
    </li>
    }
    
    @if (Model.CatePriceRangeList.Length > 0)
    {
    <li>
        <a href="javascript:void(0)" onclick="filterItemSH(this)" class="dt">价格</a>
        <div class="selectCon">
            <ul>
                <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", 0 }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (Model.FilterPrice == 0)
                                                                                                                                                                                                                                                                                       { <text>class="on"</text>}><span>不限</span></a></li>
                @for (int i = 0; i < Model.CatePriceRangeList.Length; i++)
                {
                <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", Model.FilterAttr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", i + 1 }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (Model.FilterPrice == (i + 1))
                                                                                                                                                                                                                                                                                           { <text>class="on"</text>}><span>@Model.CatePriceRangeList[i]</span></a></li>
                }
            </ul>
        </div>
    </li>
    }
    
    @{
        int order = 1;
        string startStr;
        string endStr;
        string centerStr;
        foreach (KeyValuePair<AttributeInfo, List<AttributeValueInfo>> item in Model.AAndVList)
        {
            if (item.Value.Count > 0)
            {
                startStr = order != 1 ? Model.FilterAttr.Substring(0, StringHelper.IndexOf(Model.FilterAttr, order - 1) + 1) : "";
                endStr = order != Model.AAndVList.Count ? Model.FilterAttr.Substring(StringHelper.IndexOf(Model.FilterAttr, order)) : "";
                centerStr = StringHelper.TrimEnd(StringHelper.TrimStart(Model.FilterAttr, startStr), endStr);
              <li>
                <a href="javascript:void(0)" onclick="filterItemSH(this)" class="dt">@item.Key.Name</a>
                <div class="selectCon">
                    <ul>
                        <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", startStr + "0" + endStr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (centerStr == "0")
                                                                                                                                                                                                                                                                                                                      { <text>class="on"</text>}><span>不限</span></a></li>
                        @foreach (AttributeValueInfo info in item.Value)
                        {
                        <li><a href="@Url.Action("category", new RouteValueDictionary { { "filterAttr", startStr + info.AttrValueId + endStr }, { "cateId", Model.CateId }, { "brandId", Model.BrandId }, { "filterPrice", Model.FilterPrice }, { "onlyStock", 0 }, { "sortColumn", 0 }, { "sortDirection", 0 }, { "page", 1 } })" @if (centerStr == info.AttrValueId.ToString())
                                                                                                                                                                                                                                                                                                                                   { <text>class="on"</text>}><span>@info.AttrValue</span></a></li>
                        }
                    </ul>
                </div>
            </li>
            }
            order++;
        }
      }

</ul>
</div>
<script type="text/javascript">
    //高度需要计算 .bg的高度 = 当前body的高度
    document.getElementById("filterBlock1").style.height = document.body.scrollHeight + "px";
</script>

@Html.Partial("_footer")
</body>
</html>
